import request from './request'

export const eventApi = {
  // 获取活动列表
  getEventList(params) {
    // 转换参数名称：page_size -> pageSize
    const backendParams = {
      page: params.page,
      pageSize: params.page_size || params.pageSize
    }
    
    return request({
      url: '/event/list',
      method: 'get',
      params: backendParams
    })
  },

  // 获取活动详情
  getEventDetail(id) {
    return request({
      url: `/event/${id}`,
      method: 'get'
    })
  },

  // 获取活动参与者列表
  getEventParticipants(id, params) {
    return request({
      url: `/event/${id}/participants`,
      method: 'get',
      params
    })
  },

  // 审核活动报名
  approveSignup(signupId, approved) {
    return request({
      url: `/event/signup/${signupId}/approve`,
      method: 'post',
      params: { approved }
    })
  },

  // 候补转正
  promoteFromWaitlist(id) {
    return request({
      url: `/event/${id}/promote-waitlist`,
      method: 'post'
    })
  },

  // 删除活动
  deleteEvent(id) {
    return request({
      url: `/event/${id}`,
      method: 'delete'
    })
  },

  // 取消活动
  cancelEvent(id, reason) {
    return request({
      url: `/event/${id}/cancel`,
      method: 'post',
      data: { reason }
    })
  },

  // 获取活动详情
  getEventDetail(id) {
    return request({
      url: `/event/${id}`,
      method: 'get'
    })
  }
}

